home *** CD-ROM | disk | FTP | other *** search
/ Compendium Deluxe 1 / LSD Compendium Deluxe 1.iso / a / programming / assembly / 60hzemu.lha / paz / 60hzEmulator.s
Encoding:
Text File  |  1993-04-18  |  26.7 KB  |  1,148 lines

  1. ;========================================================================
  2. ;60Hz emulator (PAL-NTSC) V1.05 by P. de Boer in 1991
  3. ;
  4. ;The program was inspired by Power Utility from Amicon and
  5. ;BootPAL/BootNTSC by Nico Francois.
  6. ;
  7. ;PS: my monitor (1084s) synchronizes from 47.5Hz to 65Hz
  8. ;    when VBI frequency is 55Hz then the monitor switches.
  9. ;
  10. ;========================================================================
  11. ;Options:
  12. ;Press : <LEFT-ALT>+<LEFT-SHIFT>+<CTRL> and :
  13. ;
  14. ; 1 - Toggle color bar
  15. ; 2 - Default values
  16. ; 3 - Add ± one line to timer buffer
  17. ; 4 - Sub ± one line to timer buffer
  18. ; 5 - Add one line to total of rasterlines (decreases VBI frequenzy)
  19. ; 6 - Sub one line from total of rasterlines (increases VBI frequenzy)
  20. ; 7 - Add one line to end of display
  21. ; 8 - Sub one line from end of display
  22.  
  23. ; ESC - To kill the emulator
  24. ; 9 - Toggle between Software and Hardware emulation
  25. ; 0 - Toggle between 50Hz and 60Hz
  26. ;
  27. ;========================================================================
  28. ;Now some stuff we need !
  29. ;========================================================================
  30.  
  31.             RSRESET        ;little structure for my flags
  32. Flag_60Hz        RS.B    1
  33. Flag_Color        RS.B    1
  34. Flag_OverScan        RS.B    1
  35. Flag_Enable        RS.B    1
  36. Flag_FatAgnus        RS.B    1
  37. Flag_Resident        RS.B    1
  38.  
  39. NULL            EQU    0
  40.  
  41. is_data            EQU    14    ;some stuff from the system's include
  42. is_code            EQU    18    ;files
  43.  
  44. gb_DisplayFlags        EQU    206    ;graphics
  45. gb_DisplayRows        EQU    212
  46. gb_NormalDisplayRows    EQU    216
  47. VBlankFrequency        EQU    530
  48.  
  49. _LVODisplayAlert    EQU    -90    ;intuition
  50.  
  51. _LVOOpen        EQU    -30    ;dos
  52. _LVOClose        EQU    -36
  53. _LVORead        EQU    -42
  54. _LVOWrite        EQU    -48
  55. _LVOInput        EQU    -54
  56. _LVOOutput        EQU    -60
  57.  
  58. MODE_OLD        EQU    1005    ;dos
  59. MODE_NEW        EQU    1006
  60. PR_CLI            EQU    $AC
  61. PR_MSGPORT        EQU    $5C
  62.  
  63. _LVOAlert        EQU    -108    ;exec
  64. _LVODisable        EQU    -120
  65. _LVOEnable        EQU    -126
  66. _LVOForbid        EQU    -132
  67. _LVOPermit        EQU    -138
  68. _LVOAddIntServer    EQU    -168
  69. _LVORemIntServer    EQU    -174
  70. _LVOAllocMem        EQU    -198
  71. _LVOFreeMem        EQU    -210
  72. _LVOAddPort        EQU    -354
  73. _LVORemPort        EQU    -360
  74. _LVOPutMsg        EQU    -366
  75. _LVOGetMsg        EQU    -372
  76. _LVOFindPort        EQU    -390
  77. _LVOCloseLibrary    EQU    -414
  78. _LVOSumLibrary        EQU    -426
  79. _LVOOpenResource    EQU    -498
  80. _LVOOpenLibrary        EQU    -552
  81. _LVOSumKickData        EQU    -612
  82. _LVOCopyMem        EQU    -624
  83.  
  84. ExecBase        EQU    $4
  85.  
  86. LIBF_CHANGED        EQU    2
  87. LIB_FLAGS        EQU    14
  88.  
  89.             RSRESET        ;node structure
  90. LN            RS.B    0
  91. LN_SUCC            RS.L    1
  92. LN_PRED            RS.L    1
  93. LN_TYPE            RS.B    1
  94. LN_PRI            RS.B    1
  95. LN_NAME            RS.L    1
  96. LN_SIZE            RS.W    0
  97.  
  98. NT_MSGPORT        EQU    4
  99. NT_MESSAGE        EQU    5
  100.  
  101.             RSRESET        ;memlist structure
  102. ML            RS.B    LN_SIZE
  103. ML_NUMENTRIES        RS.W    1
  104. ML_ME            RS.W    0
  105. ML_SIZE            RS.W    0
  106.  
  107.             RSRESET
  108. ME            RS.B    0
  109. ME_REQS            RS.W    0
  110. ME_ADDR            RS.L    1
  111. ME_LENGTH        RS.L    1
  112. ME_SIZE            RS.W    0
  113.  
  114. MEMF_PUBLIC        EQU    1<<0
  115. MEMF_CHIP        EQU    1<<1
  116.  
  117.             RSRESET        ;resident structure
  118. RT            RS.B    0
  119. RT_MATCHWORD        RS.W    1
  120. RT_MATCHTAG        RS.L    1
  121. RT_ENDSKIP        RS.L    1
  122. RT_FLAGS        RS.B    1
  123. RT_VERSION        RS.B    1
  124. RT_TYPE            RS.B    1
  125. RT_PRI            RS.B    1
  126. RT_NAME            RS.L    1
  127. RT_IDSTRING        RS.L    1
  128. RT_INIT            RS.L    1
  129. RT_SIZE            RS.W    0
  130.  
  131. RTC_MATCHWORD        EQU    $4AFC
  132. RTB_COLDSTART        EQU    0
  133. RTF_COLDSTART        EQU    1<<0
  134. RTB_AUTOINIT        EQU    7
  135. RTF_AUTOINIT        EQU    1<<7
  136. RTM_WHEN        EQU    1
  137. RTW_NEVER        EQU    0
  138. RTW_COLDSTART        EQU    1
  139.  
  140. KickMemPtr        EQU    546    ;execbase equ's
  141. KickTagPtr        EQU    550
  142. KickCheckSum        EQU    554    
  143.  
  144. DMACONR            EQU    $002    ;custom chip addresses
  145. VPOSR            EQU    $004
  146. VHPOSR            EQU    $006
  147. VPOSW            EQU    $02A
  148. VHPOSW            EQU    $02C
  149. DIWSTRT            EQU    $08E
  150. DIWSTOP            EQU    $090
  151. DMACON            EQU    $096
  152. COLOR00            EQU    $180
  153. BEAMCON0        EQU    $1DC
  154. CUSTOM            EQU    $DFF000
  155.  
  156. CIAB        EQU    $BFD000
  157. CIAA        EQU    $BFE001
  158.  
  159. PRA        EQU    $000
  160. PRB        EQU    $100
  161. DDRA        EQU    $200
  162. DDRB        EQU    $300
  163. TALO        EQU    $400
  164. TAHI        EQU    $500
  165. TBLO        EQU    $600
  166. TBHI        EQU    $700
  167. SPx        EQU    $C00
  168. ICR        EQU    $D00
  169. CRA        EQU    $E00
  170. CRB        EQU    $F00
  171.  
  172. ;========================================================================
  173. CALL        MACRO
  174.         IFC    'EXEC','\1'
  175.         MOVEA.L    (ExecBase).W,A6
  176.         ENDC
  177.         IFNC    'EXEC','\1'
  178.         MOVEA.L    \1Base,A6
  179.         ENDC
  180.         JSR    _LVO\2(A6)
  181.         ENDM
  182.  
  183. OPENLIB        MACRO
  184.         LEA    \1Name(PC),A1
  185.         CLR.L    D0
  186.         CALL    EXEC,OpenLibrary
  187.         MOVE.L    D0,\1Base
  188.         BEQ    \2
  189.         ENDM
  190.  
  191. CLOSELIB    MACRO
  192.         MOVEA.L    \1Base,A1
  193.         CALL    EXEC,CloseLibrary
  194.         ENDM
  195.  
  196. ;========================================================================
  197. ;Here we go !!!
  198. ;========================================================================
  199.         opt    o+
  200.  
  201. InstallEmulator    move.l    a0,a5            ;store pointer to cmd line
  202.         st    Flag_Resident+Flags
  203.  
  204. ;===============================================
  205. CheckForAgnus    move.w    $DFF004,d0        ;check what kind of agnus
  206.         and.w    #$2000,d0        ;we got
  207.         beq.s    .OldAgnus
  208.         st    Flag_FatAgnus+Flags
  209. .OldAgnus
  210. ;===============================================
  211. OpenDosLib    OPENLIB    DOS,NoDOS        ;open dos library
  212.         CALL    DOS,Output        ;get standart output chanel
  213.         move.l    d0,OutHandle        ;store it
  214.         beq.s    .Skip            ;if not available then skip
  215.         move.l    OutHandle(pc),d1
  216.         move.l    #Hello.TXT,d2
  217.         move.l    #Hello.LEN,d3
  218.         CALL    DOS,Write        ;print message
  219. .Skip
  220. ;===============================================
  221. SearchFlagOpt    movea.l    a5,a0            ;search for any flag options
  222. .SearchLoop    move.b    (a0)+,d0
  223.         cmp.b    #$0A,d0            ;jump out of loop if we
  224.         beq.s    Search            ;find a return
  225.         cmp.b    #"?",d0            ;an request for info ?
  226.         beq.s    .PrintSyntax
  227.         ori.b    #$20,d0            ;make lower case (quick &dirty)
  228.         cmp.b    #"a",d0            ;ignore BIG-FAT-Agnus ?
  229.         beq.s    .OverRide
  230.         cmp.b    #"r",d0            ;non resident install ?
  231.         bne.s    .SearchLoop
  232.  
  233. .Resident    SF    Flag_Resident+Flags    ;clear Resident flag
  234.         bra.s    .SearchLoop
  235. .OverRide    SF    Flag_FatAgnus+Flags    ;clear FAT agnus flag
  236.         bra.s    .SearchLoop
  237.  
  238. .PrintSyntax    move.l    #Syntax.TXT,d2        ;Print syntax if we've found
  239.         move.l    #Syntax.LEN,d3        ;an '?'
  240.         jmp    PrintMsgAndQuit(pc)
  241.  
  242. ;===============================================
  243. Search        movea.l    a5,a0            ;search for install options
  244. .SearchLoop    move.b    (a0),d0
  245.         cmp.b    #"i",d0
  246.         beq.s    InstallNTSC
  247.         cmp.b    #"I",d0
  248.         beq.s    InstallPAL
  249.         ori.b    #$20,d0            ;always lower case
  250.         cmp.b    #"k",d0
  251.         beq.s    Remove
  252.         cmp.b    #$0A,(a0)+
  253.         bne.s    .SearchLoop
  254.  
  255.         lea    MyPortName(PC),a1    ;search emulator msg.port
  256.         CALL    EXEC,FindPort        ;find my port
  257.         tst.l    d0
  258.         beq.s    InstallNTSC
  259.  
  260.         move.l    #Already.TXT,d2
  261.         move.l    #Already.LEN,d3
  262.         jmp    PrintMsgAndQuit(pc)
  263.  
  264. ;===============================================
  265. Remove        BSR    RemoveTag
  266.         jmp    PrintMsgAndQuit(pc)
  267.  
  268. InstallNTSC    sf    Flag_60Hz+Flags        ;install and start NTSC
  269.         bra.s    Install
  270. InstallPAL    st    Flag_60Hz+Flags        ;install and Start PAL
  271.  
  272. Install        lea    MyPortName(PC),a1    ;search emulator msg.port
  273.         CALL    EXEC,FindPort        ;find my port
  274.         tst.l    d0
  275.         beq.s    .NotInstalled
  276.  
  277.         lea    Message(pc),a1        ;send message to emulator
  278.         move.l    #'50'<<16,d2
  279.         tst.b    Flag_60Hz+Flags
  280.         bne.s    .pal
  281.         move.l    #'60'<<16,d2
  282.  
  283. .pal        move.b    Flag_FatAgnus+Flags(pc),d2
  284.         move.l    d2,20(a1)
  285.  
  286.         move.l    d0,a0            ;found port
  287.         CALL    EXEC,PutMsg
  288.  
  289. .Waitting    cmp.l    Message.TXT(pc),d2    ;waiting for return msg
  290.         beq.s    .Waitting
  291.  
  292.         tst.l    Message.TXT        ;message = 0 ??
  293.         bne.s    .Error            ;no -> something wrong
  294.  
  295.         move.l    #Changed.TXT,d2
  296.         move.l    #Changed.LEN,d3
  297.         bra.w    PrintMsgAndQuit
  298.  
  299. .Error        move.l    #UnChanged.TXT,d2
  300.         move.l    #UnChanged.LEN,d3
  301.         bra.s    PrintMsgAndQuit
  302.  
  303. ;===============================================
  304. .NotInstalled    BSR    InstallTag        ;install Tag
  305.         bne.s    PrintMsgAndQuit
  306.  
  307. TagInstalled    jsr    4(a0)            ;Initialize emulator
  308.         beq.s    EmulatorOn
  309.  
  310.         BSR    RemoveTag        ;kill romtag if something wrong
  311.  
  312.         move.l    #Failure.TXT,d2
  313.         move.l    #Failure.LEN,d3
  314.         bra.s    PrintMsgAndQuit
  315.  
  316. EmulatorOn    tst.b    Flag_FatAgnus+Flags
  317.         beq.s    .Skip
  318.  
  319.         move.l    #NewAgnus.TXT,d2
  320.         move.l    #NewAgnus.LEN,d3
  321.         move.l    OutHandle(pc),d1
  322.         beq.s    .Skip
  323.         CALL    DOS,Write        ;print agnus message
  324.  
  325. .Skip        tst.b    Flag_Resident+Flags
  326.         bne.s    .Skip2
  327.  
  328.         move.l    #NResident.TXT,d2
  329.         move.l    #NResident.LEN,d3
  330.         move.l    OutHandle(pc),d1
  331.         beq.s    .Skip2
  332.         CALL    DOS,Write        ;print resident message
  333.  
  334. .Skip2        move.l    #Installed.TXT,d2
  335.         move.l    #Installed.LEN,d3
  336.  
  337. ;===============================================
  338. PrintMsgAndQuit    BSR.S    DoMessage
  339.  
  340.         CLOSELIB    DOS        ;close dos library
  341.  
  342. NoDOS        clr.l    d0
  343.         rts
  344.  
  345. DoMessage    move.l    OutHandle(pc),d1
  346.         beq.s    .Skip
  347.         CALL    DOS,Write
  348.  
  349. .Skip        rts
  350.  
  351. RemoveTag    lea    MyPortName(PC),a1    ;search emulator msg.port
  352.         CALL    EXEC,FindPort        ;find my port
  353.         tst.l    d0
  354.         bne.s    FoundMyPort
  355.  
  356.         move.l    #Unable.TXT,d2        ;can't find port !
  357.         move.l    #Unable.LEN,d3
  358.         moveq    #0,d0
  359.         rts
  360.  
  361. FoundMyPort    move.l    d0,a0            ;found port
  362.         lea    Message(pc),a1        ;send message to emulator
  363.         move.l    #'KILL',20(a1)        ;kill MSG
  364.         CALL    EXEC,PutMsg        ;to remove itself.
  365.  
  366. Waitting    cmp.l    #'KILL',Message.TXT    ;waiting for return msg
  367.         beq.s    Waitting
  368.  
  369.         tst.l    Message.TXT        ;message = 0 ??
  370.         bne.s    .Error            ;no -> something wrong
  371.  
  372. .Killed        move.l    #Removed.TXT,d2        ;all well, print remove
  373.         move.l    #Removed.LEN,d3        ;message
  374.         moveq    #-1,d0
  375.         rts
  376.  
  377. .Error        move.l    #Unable.TXT,d2        ;no -> something went
  378.         move.l    #Unable.LEN,d3        ;wrong
  379.         moveq    #-1,d0
  380.         rts
  381.  
  382.  
  383. ;========================================================================
  384. Message        DC.L    0            ;message to emulator
  385.         DC.L    0
  386.         DC.B    NT_MESSAGE
  387.         DC.B    0
  388.         DC.L    0
  389.         DC.L    0            ;reply port: geen
  390.         DC.W    Message.LEN
  391. Message.TXT    DC.B    "KILL"
  392. Message.LEN    EQU    *-Message.TXT
  393.  
  394.  
  395. DOSName        DC.B    "dos.library",$0
  396.         EVEN
  397. DOSBase        DC.L    0
  398. CodeMem        DC.L    0
  399. OutHandle    DC.L    0
  400.  
  401. Hello.TXT    DC.B    $9B,"33;1m60Hz Emulator"
  402.         DC.B    $9B,"0m V1.05 by P. de Boer",$0A
  403. Hello.LEN    EQU    *-Hello.TXT
  404.  
  405. Syntax.TXT    DC.B    "This program is shareware, NOT public domain !"
  406.         DC.B    $0A
  407.         DC.B    "Read the 60Hz.DOC file for more information !"
  408.         DC.B    $0A,$0A
  409.         DC.B    $9B,"1;33mSyntax....:"
  410.         DC.B    $9B,"0m 60Hz <OPTIONS>",$0A
  411.         DC.B    $9B,"1;33mOptions...:",$9B,"0m "
  412.         DC.B    "i   = Install emulator and jump in NTSC mode.",$0A
  413.         DC.B    "            "
  414.         DC.B    "I   = Install emulator and jump in PAL mode.",$0A
  415.         DC.B    "            "
  416.         DC.B    "K/k = Kill emulator !",$0A
  417.         DC.B    $9B,"1;33mAdditional:",$9B,"0m "
  418.         DC.B    "R/r = Install emulator NON-resident in memory",$0A
  419.         DC.B    "            "
  420.         DC.B    "A/a = Ignore BIG FAT-Agnus, i.e. always software"
  421.         DC.B    " emulation",$0A,$0A
  422.         DC.B    "When the emulator is installed, ",$0A
  423.         DC.B    "press <LEFT-ALT>+<LEFT-SHIFT>+<CTRL> and ",$0A
  424.         DC.B    "  ESC - To remove the emulator from memory",$0A
  425.         DC.B    "    0 - To toggle between PAL and NTSC",$0A
  426.         DC.B    "    9 - To toggle between Software and Hardware"
  427.         DC.B    " emulation",$0A
  428.         DC.B    "  1-8 - Reserved options (read 60Hz.DOC)",$0A
  429.         DC.B    $0A
  430. Syntax.LEN    EQU    *-Syntax.TXT
  431.  
  432. NoMem.TXT    DC.B    "Not enough memory for emulator (I only need "
  433.         DC.B    "±2800 Bytes) !",$0A
  434. NoMem.LEN    EQU    *-NoMem.TXT
  435.  
  436. Changed.TXT    DC.B    "60Hz Emulator flags updated !",$0A
  437. Changed.LEN    EQU    *-Changed.TXT
  438.  
  439. UnChanged.TXT    DC.B    "Unable to update 60Hz Emulator flags !",$0A
  440. UnChanged.LEN    EQU    *-UnChanged.TXT
  441.  
  442. Installed.TXT    DC.B    "60Hz Emulator installed !",$0A
  443. Installed.LEN    EQU    *-Installed.TXT
  444.  
  445. Already.TXT    DC.B    "60Hz Emulator was already installed !",$0A
  446. Already.LEN    EQU    *-Already.TXT
  447.  
  448. Removed.TXT    DC.B    "60Hz Emulator removed !",$0A
  449. Removed.LEN    EQU    *-Removed.TXT
  450.  
  451. Unable.TXT    DC.B    "Unable to find Emulator in memory !",$0A
  452. Unable.LEN    EQU    *-Unable.TXT
  453.  
  454. Failure.TXT    DC.B    "Installation failed !",$0A
  455. Failure.LEN    EQU    *-Failure.TXT
  456.  
  457. NewAgnus.TXT    DC.B    "Fantastic, you got a BIG FAT-Agnus !!",$0A
  458. NewAgnus.LEN    EQU    *-NewAgnus.TXT
  459.  
  460. NResident.TXT    DC.B    "Emulator will be gone after reset !",$0A
  461. NResident.LEN    EQU    *-NResident.TXT
  462.  
  463.         EVEN
  464.  
  465. ;========================================================================
  466. InstallTag    move.l    #TagCodeLen,d0        ;allocate memory for
  467.         moveq    #MEMF_CHIP,d1        ;emulator
  468.         CALL    EXEC,AllocMem
  469.         tst.l    d0
  470.         bne.s    CopyTagCode
  471.  
  472.         move.l    #NoMem.TXT,d2        ;not enough memory ??
  473.         moveq    #NoMem.LEN,d3
  474.         moveq    #-1,d0
  475.         rts
  476.  
  477. CopyTagCode    movea.l    d0,a5            ;a5 holds address of copy
  478.         lea    TagCode(PC),a0        ;copy code
  479.         movea.l    d0,a1
  480.         move.l    #TagCodeLen,d0
  481.         CALL    EXEC,CopyMem
  482.  
  483.         lea    Flags(pc),a0
  484.         tst.b    Flag_Resident(a0)
  485.         beq.s    InitPort
  486.  
  487.         CALL    EXEC,Forbid        ;shut down system
  488.         CALL    EXEC,Disable
  489.  
  490.         lea    RomTagPtrs-TagCode(a5),a0
  491.         move.l    KickTagPtr(a6),4(a0)
  492.         beq.s    NoTagYet
  493.         bset    #7,4(a0)        ;set bit 31 if tag was set
  494.  
  495. NoTagYet    move.l    a0,KickTagPtr(a6)    ;install my romtag
  496.         lea    MyRomTag-TagCode(a5),a1
  497.         move.l    a1,(a0)
  498.  
  499. InitMemList    lea    MyMemList-TagCode(a5),a1
  500.         move.l    a5,ML_SIZE+ME_ADDR(a1)
  501.         move.l    KickMemPtr(a6),d0
  502.         move.l    d0,LN_SUCC(a1)
  503.         move.l    a1,KickMemPtr(a6)    ;install my memlist
  504.  
  505. InitRomTag    lea    MyRomTag-TagCode(a5),a1
  506.         move.l    a1,RT_MATCHTAG(a1)
  507.         lea    RT_SIZE(a1),a2
  508.         move.l    a2,RT_ENDSKIP(a1)
  509.         lea    ProjectName-TagCode(a5),a2
  510.         move.l    a2,RT_NAME(a1)
  511.         move.l    a5,RT_INIT(a1)
  512.         CALL    EXEC,SumKickData
  513.         move.l    d0,KickCheckSum(a6)    ;recalculate checksum
  514.  
  515. InitPort    lea    MyPortName-TagCode(a5),a0
  516.         lea    MyPort-TagCode(a5),a1
  517.         clr.l    LN_SUCC(a1)
  518.         clr.l    LN_PRED(a1)
  519.         move.l    a0,LN_NAME(a1)
  520.         CALL    EXEC,AddPort        ;add my port
  521.  
  522.         CALL    EXEC,Enable        ;powerup system
  523.         CALL    EXEC,Permit
  524.  
  525. Exit        movea.l    a5,a0            ;pass code address
  526.         clr.l    d0
  527.         rts
  528.  
  529. ;========================================================================
  530. ;This piece of code will be resident in memory !
  531. ;========================================================================
  532.  
  533.         opt    p+        ;code MUST be PC-relative !!!!
  534.  
  535. TagCode        JMP    InitTagCode(pc)        ;jump table
  536.         JMP    InitEmulator(pc)
  537.  
  538. ;========================================================================
  539. InitTagCode    movem.l    d0-d7/a0-a6,-(SP)    ;this routine
  540.                         ;will be executed
  541.         lea    MyPort(pc),a1        ;in the reset routine
  542.         lea    MyPortName(PC),a0
  543.         clr.l    LN_SUCC(a1)
  544.         clr.l    LN_PRED(a1)
  545.         move.l    a0,LN_NAME(a1)
  546.         CALL    EXEC,AddPort
  547.  
  548.         BSR.S    InitEmulator        ;re-init emulator
  549.  
  550. EndTagCode    movem.l    (SP)+,d0-d7/a0-a6    ;return to kicky
  551.         rts
  552.  
  553. ;========================================================================
  554. InitEmulator    BSR.S    InitStructures
  555.  
  556.         lea    Flags(pc),a0
  557.         sf    Flag_Enable(a0)    ;prevent interrupt
  558.         BSR.S    OpenIntLib    ;open int library (for alerts)
  559.         BSR.S    OpenResource    ;open ciab.resource (for timer)
  560.         BNE.S    .Failure
  561.         BSR    PatchSystem    ;patch system to pal/ntsc
  562.         BNE.S    .Failure
  563.         BSR    AddServers    ;add ciaa & vblank servers
  564.  
  565.         clr.l    d0
  566. .Failure    rts
  567.  
  568. ;========================================================================
  569. Alert        clr.l    d0            ;display alert
  570.         moveq    #32,d1
  571.         movea.l    INTBase(pc),a6
  572.         jsr    _LVODisplayAlert(a6)
  573.         rts
  574. ;===============================================
  575. OpenIntLib    lea    INTName(pc),a1
  576.         clr.l    d0
  577.         CALL    EXEC,OpenLibrary
  578.         lea    INTBase(pc),a0
  579.         move.l    d0,(a0)
  580.         bne.s    .Skip
  581.         rts
  582.         move.l    #$04030000,d7        ;software failure
  583.         lea    $FC00D2,a5        ;if intuition.library
  584.         CALL    EXEC,Alert        ;didn't open
  585. .Skip        rts
  586. ;===============================================
  587. InitStructures    lea    TagCode(pc),a0        ;relocate structures !
  588.         move.l    a0,d0
  589.         lea    CIAA_Server(pc),a0
  590.         BSR.S    .InitStruct
  591.         lea    CIAB_Server(pc),a0
  592.         BSR.S    .InitStruct
  593.         lea    VBI_Server(pc),a0
  594. .InitStruct    add.l    d0,LN_NAME(a0)
  595.         add.l    d0,is_data(a0)
  596.         add.l    d0,is_code(a0)
  597.         lea    InitStructures(pc),a0
  598.         move.w    #$4E75,(a0)        ;put RTS at InitStruct
  599.         rts
  600. ;===============================================
  601. OpenResource    lea    CIABName(pc),a1        ;open ciab.resource
  602.         clr.l    d0
  603.         CALL    EXEC,OpenResource
  604.         lea    CIABBase(pc),a0
  605.         move.l    d0,(a0)
  606.         beq.s    .Error
  607.         moveq    #0,d0
  608.         rts
  609. .Error        lea    NoResourceAlert(pc),a0    ;no resource ??
  610.         BSR    Alert
  611.         moveq    #-1,d0
  612.         rts
  613.  
  614. ;===============================================
  615. AllocateTimer    move.b    #0,d0            ;timer a interrupt
  616.         lea    CIAB_Server(pc),a1
  617.         move.l    CIABBase(pc),a6
  618.         jsr    -6(a6)            ;set interrupt
  619.         lea    TimerStat(pc),a0
  620.         move.l    d0,(a0)            ;store timer status
  621.         beq.s    .Ok
  622.  
  623. .Error        lea    NoTimerAlert(pc),a0    ;no timer !
  624.         BSR    Alert
  625.         moveq    #-1,d0
  626. .Ok        rts
  627.  
  628. ;===============================================
  629. DeAllocateTimer    lea    TimerStat(pc),a0
  630.         tst.l    (a0)
  631.         bne.s    .Skip
  632.         move.b    #0,d0
  633.         move.l    CIABBase(pc),a6
  634.         jsr    -12(a6)            ;clr interrupt
  635.  
  636.         lea    TimerStat(pc),a0
  637.         moveq    #-1,d0
  638.         move.l    d0,(a0)
  639.  
  640. .Skip        rts
  641.  
  642. ;===============================================
  643. AddServers    lea    Flags(pc),a0
  644.         sf    Flag_Enable(a0)
  645.  
  646.         move.w    #$0005,d0        ;vertical blank interrupt
  647.         lea    VBI_Server(pc),a1
  648.         CALL    EXEC,AddIntServer
  649.         move.w    #$0003,d0        ;keyboard interrupt
  650.         lea    CIAA_Server(pc),a1
  651.         CALL    EXEC,AddIntServer
  652.  
  653.         lea    Flags(pc),a0
  654.         st    Flag_Enable(a0)
  655.  
  656.         rts
  657. ;===============================================
  658. PatchSystem    lea    Flags(pc),a0        ;this routine does it !
  659.         tst.b    Flag_60Hz(a0)
  660.         beq.s    Go60
  661.  
  662. ;===============================================
  663. Go50        tst.b    Flag_FatAgnus(a0)    ;put system in PAL mode
  664.         bne.s    .Go50
  665.         BSR.S    DeAllocateTimer        ;free timers
  666.  
  667. .Go50        move.w    #$0020,BEAMCON0!CUSTOM    ;very simple if we have a FAT
  668.  
  669.         lea    Flags(pc),a0
  670.         sf    Flag_Enable(a0)        ;stop it
  671.  
  672.         lea    GFXName(PC),a1
  673.         clr.l    d0
  674.         CALL    EXEC,OpenLibrary    ;open graphics library
  675.         move.l    d0,a1
  676.         move.w    gb_DisplayFlags(a1),d0    ;adjust display flags
  677.         and.b    #%11111110,d0        ;erase NTSC flag
  678.         or.b    #%00000100,d0        ;set PAL flag
  679.         move.w    d0,gb_DisplayFlags(a1)
  680.         move.w    #256,gb_NormalDisplayRows(a1)
  681.         move.w    #311,gb_DisplayRows(a1)
  682.         or.b    #LIBF_CHANGED,LIB_FLAGS(a1)
  683.         movea.l    a1,a2
  684.         CALL    EXEC,SumLibrary        ;caluclate checksum
  685.         movea.l a2,a1
  686.         CALL    EXEC,CloseLibrary    ;close lib again
  687.         move.b    #50,VBlankFrequency(a6)    ;change EXEC library
  688.         or.b    #LIBF_CHANGED,LIB_FLAGS(a6)
  689.         CALL    EXEC,SumLibrary        ;calculate checksum
  690.         moveq    #0,d0
  691.         rts
  692.  
  693. ;===============================================
  694. Go60        tst.b    Flag_FatAgnus(a0)    ;put system in NTSC mode
  695.         beq.s    .NoFatty
  696.  
  697.         move.w    #$0000,BEAMCON0!CUSTOM    ;to NTSC please
  698.         bra.s    .Go60
  699.  
  700. .NoFatty    move.w    #$0020,BEAMCON0!CUSTOM
  701.         BSR    AllocateTimer        ;allocate timers again
  702.         bne.s    .Error            ;not available
  703.  
  704. .Go60        lea    GFXName(PC),a1        ;modify graphics.library
  705.         clr.l    d0
  706.         CALL    EXEC,OpenLibrary
  707.         move.l    d0,a1
  708.         move.w    gb_DisplayFlags(a1),d0
  709.         and.b    #%11111011,d0
  710.         or.b    #%00000001,d0
  711.         move.w    d0,gb_DisplayFlags(a1)
  712.         move.w    #200,gb_NormalDisplayRows(a1)
  713.         move.w    #262,gb_DisplayRows(a1)
  714.         or.b    #LIBF_CHANGED,LIB_FLAGS(a1)
  715.         movea.l    a1,a2
  716.         CALL    EXEC,SumLibrary
  717.         movea.l    a2,a1
  718.         CALL    EXEC,CloseLibrary
  719.         move.b    #60,VBlankFrequency(a6)
  720.         or.b    #LIBF_CHANGED,LIB_FLAGS(a6)
  721.         CALL    EXEC,SumLibrary
  722.  
  723.         lea    Flags(pc),a0
  724.         st    Flag_Enable(a0)        ;start it
  725.         moveq    #0,d0
  726.         rts
  727.  
  728. .Error        lea    Flags(pc),a0
  729.         st    Flag_60Hz(a0)
  730.         sf    Flag_Enable(a0)        ;stop it
  731.         moveq    #-1,d0
  732.         rts
  733.  
  734. ;========================================================================
  735. CIAA_Server_Int    movem.l    d0-d7/a0-a6,-(SP)    ;keyboard interrupt
  736.  
  737.         st    d1            ;server
  738.         lea    EnterKeys(pc),a0
  739.         move.b    CIAA!SPx,d5
  740.         not.b    d5
  741.         ror.b    #1,d5
  742.         bmi.s    .NotPressed
  743.         sf    d1
  744. .NotPressed    andi.b    #$7F,d5
  745. .TestCTRL    cmp.b    #$63,d5
  746.         bne.s    .TestSHIFT
  747.         move.b    d1,(a0)        
  748. .TestSHIFT    cmp.b    #$60,d5
  749.         bne.s    .TestALT
  750.         move.b    d1,1(a0)        
  751. .TestALT    cmp.b    #$64,d5
  752.         bne.s    .EndTest
  753.         move.b    d1,2(a0)        
  754. .EndTest    tst.b    d1
  755.         bne.s    CIAA_Return
  756.  
  757. AreWeInControl    tst.l    (a0)
  758.         bne.s    CIAA_Return
  759.         cmp.b    #$45,d5
  760.         beq.s    .Go
  761.         cmp.b    #$0A,d5
  762.         bgt.s    CIAA_Return
  763.  
  764. .Go        ori.b    #$40,CIAA!CRA
  765.         nop
  766.         nop
  767.         andi.b    #$BF,CIAA!CRA
  768.         nop
  769.         nop
  770.         clr.b    CIAA!SPx
  771.  
  772.         lea    Flags(pc),a5
  773.         BSR    CheckESC
  774.         tst.b    Flag_Enable(a5)
  775.         beq.s    .Skip
  776.         tst.b    Flag_FatAgnus(a5)
  777.         bne.s    .Skip
  778.         BSR    CheckColor        ;check keys
  779.         BSR    CheckTime
  780.         BSR    CheckStartPos
  781.         BSR    CheckEndPos
  782.         BSR    CheckDefault
  783. .Skip        BSR    Check60Hz
  784.         BSR    CheckAgnus
  785. CIAA_Return    movem.l    (SP)+,d0-d7/a0-a6
  786.         DC.W    $003C,$0004
  787.         rts
  788.  
  789. ;========================================================================
  790. VBI_Server_Int    movem.l    d0-d7/a0-a6,-(SP)    ;vertical blank interrupt
  791.  
  792.         lea    Flags(pc),a0        ;server
  793.         tst.b    Flag_Enable(a0)        ;are we in 60Hz mode ?
  794.         beq.s    .Skip            ;if not then skip
  795.  
  796.         lea    CUSTOM,a0        ;custom chip base
  797.         move.w    DMACONR(a0),d1        ;read DMACON
  798.         move.w    #$0440,DMACON(a0)    ;clear blitpri & blitdma
  799.  
  800.         clr.w    d0
  801.         move.b    VHPOSR(a0),d0        ;read actual beam pos
  802.         neg.w    d0            ;make it negative
  803.         add.w    EndPos(pc),d0        ;add endpos
  804.         mulu    #45,d0            ;multiply with cycle/line
  805.         sub.w    VBITime(pc),d0        ;subtrack buffer time
  806.         move.b    d0,$bfd400        ; Timer A high byte
  807.         lsr.w    #8,d0            ;get low byte
  808.         move.b    d0,$bfd500        ; Timer A low byte
  809.         move.b    #%00011001,$BFDE00    ;load timer-a
  810.  
  811.         andi.w    #$0440,d1        ;reinstall dma again
  812.         ori.w    #$8000,d1
  813.         move.w    d1,DMACON(a0)        ;write it in dmacon
  814.  
  815. .Skip        BSR.S    CheckForMSG        ;check for incoming msg
  816.  
  817.         movem.l    (SP)+,d0-d7/a0-a6
  818.         DC.W    $003C,$0004        ;or.w #$4,SR ;set Z-Flag
  819.         rts
  820.  
  821. ;========================================================================
  822. CIAB_Server_Int    movem.l    d0-d2/a0,-(a7)
  823.         lea    Flags(pc),a0
  824.         tst.b    Flag_Enable(a0)
  825.         beq.s    GetOutOfHere
  826.         lea    CUSTOM,a0        ;get custom base address
  827.         move.w    DMACONR(a0),d2        ;read dma
  828.         move.w    #$0440,DMACON(a0)    ;clear blitpri&blitdma
  829.         move.w    EndPos(pc),d1
  830.         lsl.w    #8,d1
  831.         ori.w    #$D1,d1
  832. StartColor    move.w    #$0505,$1FE(a0)        ;put colorbar if needed
  833.         move.w    EndPos(pc),d0        ;wait for line 'EndPos'
  834. WaitLine    cmp.b    VHPOSR(a0),d0
  835.         bgt.s    WaitLine
  836.         move.w    d1,DIWSTOP(a0)
  837. EndColor    move.w    #$0000,$1FE(a0)
  838.         move.l    StartPos(pc),d1
  839.         move.l    VPOSR(a0),d0        ;prevents shocking
  840.         sub.l    VPOSR(a0),d0        ;of menu bar
  841.         sub.l    d0,d1            ;subtract it from StartPos
  842.         add.l    VPOSR(a0),d1        ;add current beam pos
  843.         move.l    d1,VPOSW(a0)        ;write new beampos
  844.         andi.w    #$0440,d2        ;
  845.         ori.w    #$8000,d2
  846.         move.w    d2,DMACON(a0)        ;enable blitpri&blitdma
  847. GetOutOfHere    movem.l    (a7)+,d0-d2/a0        ;return to system
  848.         rts
  849.  
  850. ;========================================================================
  851. CheckForMSG    lea    MyPort(pc),a0        ;check message port
  852.         CALL    EXEC,GetMsg        ;get message
  853.         tst.l    d0
  854.         beq.s    .NoMSG            ;mmmm.. no message
  855.  
  856.         move.l    d0,a5            ;got message, yeah !
  857.         cmp.l    #"KILL",20(a5)        ;is it a 'KILL' message ??
  858.         beq.s    MSG.Kill
  859.  
  860.         move.l    20(a5),d2
  861.  
  862.         lea    Flags(pc),a4
  863.         cmp.b    Flag_FatAgnus(a4),d2    ;change in emulation mode ?
  864.         beq.s    .Skip            ;no then skip
  865.  
  866.         tst.b    Flag_FatAgnus(a4)
  867.         beq.s    .DeAllocTimer
  868.         BSR    AllocateTimer
  869.         bne.s    .Skip
  870.  
  871. .DeAllocTimer    BSR    DeAllocateTimer
  872.         not.b    Flag_FatAgnus(a4)
  873.  
  874. .Skip        swap    d2
  875.         cmp.w    #"50",d2
  876.         beq.s    MSG.50Hz
  877.         cmp.w    #"60",d2
  878.         beq.s    MSG.60Hz
  879.  
  880. .Exit        move.l    d0,20(a5)
  881.  
  882. .NoMSG        rts
  883.  
  884. MSG.50Hz    lea    Flags(pc),a0        ;recieved 50Hz message
  885.         tst.b    Flag_60Hz(a0)
  886.         bne.s    .Already50Hz
  887.         st    Flag_60Hz(a0)
  888.         BSR    PatchSystem
  889. .Already50Hz    clr.l    20(a5)
  890.         rts
  891.  
  892. MSG.60Hz    lea    Flags(pc),a0        ;recieved 60Hz message
  893.         tst.b    Flag_60Hz(a0)
  894.         beq.s    .Already60Hz
  895.         sf    Flag_60Hz(a0)
  896.         BSR    PatchSystem
  897.         move.l    d0,20(a5)
  898.         rts
  899. .Already60Hz    clr.l    20(a5)
  900.         rts
  901.  
  902. MSG.Kill    BSR    KillEmulator        ;yes? -> kill me (?)
  903.         move.l    d0,20(a5)
  904.         rts
  905.  
  906. ;========================================================================
  907. ;Subroutines for key checking !
  908. ;
  909. ;=======================================
  910. CheckColor    cmp.b    #$01,d5
  911.         bne.s    .NoColorFlag
  912.         lea    EndColor+4(pc),a1    ;self-modifying code
  913.         lea    StartColor+4(pc),a2    ;not so nice, but it works
  914.         not.b    Flag_Color(a5)
  915.         beq.s    .ColorOff
  916. .ColorOn    move.w    #COLOR00,(a1)        ;
  917.         move.w    #COLOR00,(a2)
  918.         bra.s    .NoColorFlag
  919. .ColorOff    move.w    #$01FE,(a1)        ;copper instruction $1FE
  920.         move.w    #$01FE,(a2)        ;is NO-OP (no operation)
  921. .NoColorFlag    rts
  922. ;=======================================
  923. CheckAgnus    cmp.b    #$09,d5
  924.         bne.s    .NoAgnusCheck
  925.  
  926.         move.w    $DFF004,d0        ;check what kind of agnus
  927.         and.w    #$2000,d0        ;we got
  928.         beq.s    .NoAgnusCheck        ;no big agnus ? how lame !
  929.  
  930.         tst.b    Flag_FatAgnus(a5)
  931.         beq.s    .DeAllocTimer
  932.         BSR    AllocateTimer
  933.         bne.s    .NoAgnusCheck
  934.  
  935. .DeAllocTimer    BSR    DeAllocateTimer
  936.         not.b    Flag_FatAgnus(a5)
  937.  
  938. .Skip        BSR    PatchSystem
  939.  
  940. .NoAgnusCheck    rts
  941. ;=======================================
  942. CheckTime    lea    VBITime(pc),a1
  943.         cmp.b    #$03,d5
  944.         beq.s    .NoAdd
  945.         sub.w    #45,(a1)
  946. .NoAdd        cmp.b    #$04,d5
  947.         beq.s    .NoSub
  948.         add.w    #45,(a1)
  949. .NoSub        rts
  950. ;=======================================
  951. CheckStartPos    lea    StartPos(pc),a1
  952.         cmp.b    #$05,d5
  953.         beq.s    .NoAdd
  954.         add.l    #$0100,(a1)
  955. .NoAdd        cmp.b    #$06,d5
  956.         beq.s    .NoSub
  957.         sub.l    #$0100,(a1)
  958. .NoSub        rts
  959. ;=======================================
  960. CheckEndPos    lea    EndPos(pc),a1
  961.         cmp.b    #$07,d5
  962.         beq.s    .NoAdd
  963.         addq.w    #$0001,(a1)
  964. .NoAdd        cmp.b    #$08,d5
  965.         beq.s    .NoSub
  966.         subq.w    #$0001,(a1)
  967. .NoSub        rts
  968. ;=======================================
  969. CheckDefault    cmp.b    #$02,d5
  970.         bne.s    .Skip
  971.         lea    EndPos(pc),a1
  972.         move.w    #$0104,(a1)
  973.         lea    StartPos(pc),a1
  974.         move.l    #$3203,(a1)
  975.         lea    VBITime(pc),a1
  976.         move.w    #8*45,(a1)
  977. .Skip        rts
  978. ;=======================================
  979. Check60Hz    cmp.b    #$0A,d5
  980.         bne.s    .Skip
  981.         not.b    Flag_60Hz(a5)
  982.         BSR    PatchSystem
  983. .Skip        rts
  984. ;=======================================
  985. CheckESC    cmp.b    #$45,d5
  986.         bne.s    .Skip
  987.         BSR.S    KillEmulator
  988. .Skip        rts
  989. ;========================================================================
  990. KillEmulator    CALL    EXEC,Disable
  991.         move.w    #$0005,d0        ;vertical blank interrupt
  992.         lea    VBI_Server(pc),a1
  993.         CALL    EXEC,RemIntServer
  994.         move.w    #$0003,d0        ;keyboard interrupt
  995.         lea    CIAA_Server(pc),a1
  996.         CALL    EXEC,RemIntServer
  997.         lea    Flags(pc),a0
  998.         st    Flag_60Hz(a0)
  999.         BSR    PatchSystem
  1000.         BSR.S    RemoveRomTag
  1001.         move.l    d0,d2
  1002.         CALL    EXEC,Enable
  1003.         rts
  1004. ;========================================================================
  1005. RemoveRomTag    lea    MyPortName(PC),a1
  1006.         CALL    EXEC,FindPort        ;find my port
  1007.         tst.l    d0
  1008.         bne.s    FoundPort
  1009.         moveq    #-1,d0            ;no port found ??
  1010.         rts
  1011.  
  1012. FoundPort    move.l    d0,a4            ;a4 = pointer to MyPort
  1013.         move.l    a4,a1
  1014.         CALL    EXEC,RemPort        ;remove it !
  1015.  
  1016.         lea    Flags(pc),a0
  1017.         tst.b    Flag_Resident(a0)
  1018.         beq.s    FreeMemory
  1019.  
  1020.         CALL    EXEC,Forbid        ;shut down system
  1021.         CALL    EXEC,Disable
  1022.  
  1023.         lea    MyMemList-MyPort(a4),a1    ;find my memlist
  1024.         lea    KickMemPtr(a6),a0
  1025. FindMyMemList    move.l    LN_SUCC(a0),d0
  1026.         cmp.l    d0,a1
  1027.         beq.s    FoundMyList
  1028.         move.l    d0,a0
  1029.         bra.s    FindMyMemList
  1030.  
  1031. FoundMyList    move.l    LN_SUCC(a1),d0        ;clear memlist from system
  1032.         move.l    d0,LN_SUCC(a0)        ; LN_SUCC = 0, so this also
  1033.                         ; works for KickMemPtr
  1034.  
  1035.         move.l    RomTagPtrs-MyPort+4(a4),KickTagPtr(a6)
  1036.         beq.s    NoSecondTag
  1037.         bclr    #7,KickTagPtr(a6)    ;clear bit 31
  1038.  
  1039. NoSecondTag    CALL    EXEC,SumKickData
  1040.  
  1041.         tst.l    KickTagPtr(a6)        ;check if one of the
  1042.         bne.s    .Set            ;ptrs is set
  1043.         tst.l    KickMemPtr(a6)        ;if so, then no need
  1044.         bne.s    .Set            ;to calc checksum
  1045.         clr.l    d0            ;so, clear it !
  1046.  
  1047. .Set        move.l    d0,KickCheckSum(a6)    ;restore old 
  1048.  
  1049.         CALL    EXEC,Enable        ;power up system
  1050.         CALL    EXEC,Permit
  1051.  
  1052. FreeMemory    lea    TagCode-MyPort(a4),a1    ;free tag memory
  1053.         move.l    #TagCodeLen,d0
  1054.         CALL    EXEC,FreeMem
  1055.  
  1056.         clr.l    d0
  1057.         rts
  1058.  
  1059. ;========================================================================
  1060. CIAA_Server    DC.L    0            ;interrupt server structure
  1061.         DC.L    0
  1062.         DC.B    2            ;type = interrupt
  1063.         DC.B    127            ;pri
  1064.         DC.L    ProjectName-TagCode
  1065.         DC.L    CIAA_Server-TagCode
  1066.         DC.L    CIAA_Server_Int-TagCode
  1067.  
  1068. CIAB_Server    DC.L    0
  1069.         DC.L    0
  1070.         DC.B    2            ;type = interrupt
  1071.         DC.B    127            ;pri
  1072.         DC.L    ProjectName-TagCode
  1073.         DC.L    CIAB_Server-TagCode
  1074.         DC.L    CIAB_Server_Int-TagCode
  1075.  
  1076. VBI_Server    DC.L    0
  1077.         DC.L    0
  1078.         DC.B    2            ;type = interrupt
  1079.         DC.B    127            ;pri
  1080.         DC.L    ProjectName-TagCode
  1081.         DC.L    VBI_Server-TagCode
  1082.         DC.L    VBI_Server_Int-TagCode
  1083.  
  1084. MyMemList    DS.B    LN_SIZE            ;memlist structure
  1085.         DC.W    1
  1086.         DC.L    NULL
  1087.         DC.L    TagCodeLen
  1088.  
  1089. MyPort        DC.L    NULL            ;message port structure
  1090.         DC.L    NULL
  1091.         DC.B    NT_MSGPORT
  1092.         DC.B    0
  1093.         DC.L    NULL
  1094.         DC.B    0
  1095.         DC.B    0
  1096.         DC.L    NULL
  1097.         DS.B    14
  1098.  
  1099. MyRomTag    DC.W    RTC_MATCHWORD        ;resident structure
  1100.         DC.L    NULL
  1101.         DC.L    NULL
  1102.         DC.B    RTF_COLDSTART
  1103.         DC.B    1
  1104.         DC.B    0
  1105.         DC.B    -10
  1106.         DC.L    NULL
  1107.         DC.L    NULL
  1108.         DC.L    0
  1109.  
  1110. ;========================================================================
  1111. ProjectName    DC.B    "60Hz emulator V1.05 by P. de Boer",$0
  1112. MyPortName    DC.B    "60Hz emulator V1.05 (port)",$0
  1113.         EVEN
  1114.  
  1115. CIABName    DC.B    "ciab.resource",$0
  1116. INTName        DC.B    "intuition.library",$0
  1117. GFXName        DC.B    "graphics.library",$0
  1118.         EVEN
  1119.  
  1120. NoTimerAlert    DC.W    20
  1121.         DC.B    17
  1122.         DC.B    "Emulator failure: "
  1123.         DC.B    "CIA-B Timer-A already in use !",$0
  1124.         EVEN
  1125.  
  1126. NoResourceAlert    DC.W    20
  1127.         DC.B    17
  1128.         DC.B    "Emulator failure: "
  1129.         DC.B    "Unable to open ciab.resource !",$0
  1130.         EVEN
  1131.  
  1132. StartPos    DC.L    $3202        ;Start pos
  1133. EndPos        DC.W    $0104
  1134.  
  1135. Flags        DCB.B    8
  1136. EnterKeys    DC.L    $FFFFFF00
  1137. VBITime        DC.W    8*45        ;buffer time (important !)
  1138.  
  1139. TimerStat    DC.L    -1
  1140. INTBase        DC.L    0
  1141. CIABBase    DC.L    0
  1142. RomTagPtrs    DCB.L    2,$0
  1143.  
  1144. TagCodeLen    EQU    *-TagCode
  1145.  
  1146. ;========================================================================
  1147. ;|
  1148.